package writtenexamination.laohu;

import java.util.ArrayList;
import java.util.Collections;

/**
 * @author cyt
 * @create 2020-10-25 下午 5:24
 */
public class Ta {
    public static void main(String[] args) {

    }

    int[] arr;
    int m;
    ArrayList<ArrayList<Integer>> res;
    public ArrayList<ArrayList<Integer>> combinationSum(int[] prices, int m) {
        // write code here
        this.arr = prices;
        this.m = m;
        this.res = new ArrayList<>();
        return this.res;
    }
    public void dfs(int index, ArrayList<Integer> tmp, int count) {
        if (index >= arr.length) {
            if (m == count) {
                ArrayList<Integer> list = new ArrayList<>(tmp);
                Collections.sort(list);
                res.add(list);
            }
            return;
        }
        if (count > m) return;
        tmp.add(arr[index]);
        dfs(index + 1, tmp, count + arr[index]);
        tmp.remove(tmp.size() - 1);
        dfs(index + 1, tmp, count);
    }

}
